package zhoujianyang;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Client {
       
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		
	  Class.forName("com.mysql.jdbc.Driver");
   	  String url = "jdbc:mysql://;localhost:3306/why";
   	  String username = "root";
   	  String password = "root";
   	  Connection conn = (Connection) DriverManager.getConnection(url,username,password);
   	  
   	  String insertSqlStatic = "insert into tb_student (age,sex,name,id) values('21','0','zhangsan','1')";
   	  Statement ps = conn.prepareStatement(insertSqlStatic);
   	 
   	  String insertSqlDynamic = "insert into tb_student (age,sex,name,id) values(?,?,?,?)";
   	  Statement dps = conn.prepareStatement(insertSqlDynamic);
   	  dps.setInt(1,22);
   	  dps.setInt(2,1);
   	  dps.setString(3,"zhangxiaohua");
   	  dps.setInt(4,2);
   	  
   	  ps.executeUpdate(insertSqlStatic);
   	  dps.executeUpdate();
	}
    	  
}